from Table import *

class Game():
    def __init__(self):
        self.table = Table()
        self.table.randomize()

        self.players = deque()
        self.players.append(Player("1"))
        self.players.append(Player("2"))
        self.players.append(Player("3"))
        self.players.append(Player("4"))

    def activePlayer(self):
        return self.players[0]

    def nextTurn(self):
        self.activePlayer().endTurn()
        self.players.append(self.players.popleft())

    

if __name__ == '__main__':
    game = Game()    
    print game
    while True:
        game.nextTurn()
        game.activePlayer().endActions()
        for pile in game.table.CardPile:
            if pile.size()>0:
                pile.buy(game.activePlayer())
                break
        text = raw_input(">>")
